package com.tpshion.chat.service.impl;

import com.tpshion.chat.domain.entity.UserInfo;
import com.tpshion.chat.domain.vo.UserInfoVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.tpshion.chat.mapper.UserInfoMapper;
import com.tpshion.chat.service.UserInfoService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService{

    @Resource
    private UserInfoMapper userInfoMapper;

    /**
     * 根据用户名查询用户信息
     * @param userName
     * @return
     */
    @Override
    public UserInfo findUserByUserName(String userName) {
        return userInfoMapper.findUserByUserName(userName);
    }

    /**
     * 有选择的新增用户
     * @param userInfo
     */
    @Override
    @Transactional
    public void addUserSelective(UserInfo userInfo) {
        userInfoMapper.addUserSelective(userInfo);
    }

    /**
     * 模糊查询用户信息
     * @param userName
     * @return
     */
    @Override
    public List<UserInfoVo> queryUserByUserName(String userName) {
        return userInfoMapper.queryUserByUserName(userName);
    }

    /**
     * 根据用户id查询用户信息
     * @param userId
     * @return
     */
    @Override
    public UserInfoVo getUsreByUserId(String userId) {
        return userInfoMapper.getUsreByUserId(userId);
    }
}
